package com.young.ysepay.controllers;


import com.young.ysepay.service.YsPaymentService;
import com.young.ysepay.utils.JSONUtils;
import com.young.ysepay.utils.ReturnUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author: WANGNING
 * @Email wyn20140226@aliyun.com
 * @Date: 2019/6/5 8:40
 * @Des 银盛代打款接口（非一清）
 */
@RestController
@RequestMapping("/ysPayment")
public class YsPaymentControllrt {
    private static Logger log = LoggerFactory.getLogger(YsPaymentControllrt.class);
    @Autowired
    private YsPaymentService ysPaymentService;
    /**
     * @Author zhaopengjun
     * @Description //银盛单笔代付接口（非一清待打款接口）
     * @Date 9:58 2019/5/24
     * @Param
     * @return
     **/
    @RequestMapping(value = { "/payment" }, produces = { "text/html;charset=UTF-8" }, method = {
            RequestMethod.POST })
    public String transferAccounts(@RequestParam Map<String,Object> mapParams){
        System.out.println("----------- 银盛非一清待打款接口---------------");

        Map<String, Object> returnMap = null;
        String responseStr = "";
        try {
            returnMap = ysPaymentService.payment(mapParams);
        } catch (Exception e) {
            returnMap = ReturnUtils.getExceptionResult(log,e);
        } finally {
            responseStr = JSONUtils.objectToJson(returnMap);
        }
        return ReturnUtils.appendResultStr(log,responseStr,"transferAccounts");
    }
    
    /**
     * @Author zhaopengjun
     * @Description //银盛非一清代付查询接口
     * @Date 15:33 2019/6/17
     * @Param 
     * @return 
     **/
    @RequestMapping(value = { "/paymentQuery" }, produces = { "text/html;charset=UTF-8" }, method = {
            RequestMethod.POST })
    public String paymentQuery ( @RequestParam Map<String, Object> mapParams){
        Map<String, Object> returnMap = null;
        String responseStr = "";
        try {
            returnMap = ysPaymentService.paymentQuery(mapParams);
        } catch (Exception e) {
            returnMap = ReturnUtils.getExceptionResult(log,e);
        } finally {
            responseStr = JSONUtils.objectToJson(returnMap);
        }
        return ReturnUtils.appendResultStr(log,responseStr,"paymentQuery");
    }
}
